The first executable p4 statement in a program should be:
This initializes the p4 system and allows p4 to extract any command
line arguments passed to it, e.g. debugging parameters.
Similarly, the last executable p4 statement in a program should be:
This waits for termination of p4 processes and performs some cleanup
operations.
The procedure p4_get_my_id returns the unique integer id assigned to the calling process by p4.
The statement:
reads a procgroup file that the user builds and creates the set of
slaves described in that file. Obviously this statement must be
executed before any slaves can be assumed to exist. This procedure
is the method you must use to create processes that do message-passing.
The procedure p4_clock returns an integer that represents wall-clock time in milliseconds. It is typically used to retrieve the time before and after some work, the difference representing the time to do that work. Note that there is also a p4_ustimer that is useful on those machines that support a microsecond timer.
The procedures p4_send and p4_sendr are two of several p4 procedures that are available for sending messages to other processes. They take as arguments the message type, the id of the "to" process, the address of the message, and the message length.
The procedure p4_recv receives a message from another process and sets the values of all four parameters. P4_recv will automatically retrieve a buffer in which to place a received message, thus p4_msg_free may be called to free that buffer when it is no longer needed.
The procedure p4_num_total_slaves is one of several procedures that the user can invoke to determine information about the current execution.
To run this program, you need to create a procgroup file that describes
where all slave processes are to be executed
(Specifying Processes in the Procgroup File). We will assume that
you have an example procgroup file (named procgroup) in the
p4/messages directory, and can run sr_test by merely typing:
If the procgroup file is elsewhere, then you must type:
Another example that is made by default is the program systest. It tests a number of the message-passing features of p4.
Specifying Processes in the Procgroup File,Developing a Simple p4 Program,Getting Started,Top